home *** CD-ROM | disk | FTP | other *** search
/ HTBasic 9.3 / HTBasic 9.3.iso / LgcyPlus / disk2 / COMBTEST._ / COMBTEST.
Encoding:
Text File  |  2001-03-02  |  1.6 KB  |  49 lines

  1. 10    ! ********************************************************
  2. 20    ! Example: COMBO Test
  3. 30    !
  4. 40    ! This program creates a COMBO widget and allows the
  5. 50    ! user to select an animal name from a defined list
  6. 60    ! of names or to enter a name from the keyboard. The
  7. 70    ! program displays an error message if the name entered
  8. 80    ! is not in the defined list.
  9. 90    !
  10. 100   ! ********************************************************
  11. 110   !
  12. 120   DIM L$(1:5)[26],S$[50]
  13. 130   INTEGER N
  14. 140   !
  15. 150   DATA " Aardvark"," Sidewinder"," Kiwi"," Pangolin"," Marmoset"
  16. 160   READ L$(*)
  17. 170   !
  18. 180   ASSIGN @Combo TO WIDGET "COMBO";SET ("SYSTEM MENU":"Quit")
  19. 190   CONTROL @Combo;SET ("TITLE":" Example: COMBO Test - Select an Animal")
  20. 200   CONTROL @Combo;SET ("BACKGROUND":1,"LIST BACKGROUND":1,"ITEMS":L$(*))
  21. 210   CONTROL @Combo;SET ("X":50,"Y":25,"WIDTH":325)
  22. 220   CONTROL @Combo;SET ("SYSTEM MENU":"Quit")
  23. 230   !
  24. 240   ON EVENT @Combo,"SELECTION" GOSUB Handler
  25. 250   ON EVENT @Combo,"RETURN" GOSUB Handler
  26. 260   ON EVENT @Combo,"SYSTEM MENU" GOTO Finis
  27. 270   !
  28. 280   LOOP
  29. 290     WAIT FOR EVENT
  30. 300   END LOOP
  31. 310   STOP
  32. 320      !
  33. 330 Handler:    !
  34. 340   STATUS @Combo;RETURN ("TEXT":S$)
  35. 350   FOR N=1 TO 5
  36. 360     IF S$=L$(N) THEN
  37. 370       S$="List item #"&VAL$(N)&": "&S$
  38. 380       DIALOG "INFORMATION",S$
  39. 390       RETURN
  40. 400     END IF
  41. 410   NEXT N
  42. 420   S$="Animal not in list: "&S$
  43. 430   DIALOG "ERROR",S$;SET ("TITLE":" Invalid Selection")
  44. 440   RETURN
  45. 450      !
  46. 460 Finis:    !
  47. 470   ASSIGN @Combo TO *  ! Delete COMBO widget
  48. 480   END
  49.